Skip to content

RFE-9311: Add workload partitioning support for must-gather pods - #2321

Open
midu16 wants to merge 1 commit into
openshift:mainfrom
midu16:RFE-9311
Open

RFE-9311: Add workload partitioning support for must-gather pods#2321
midu16 wants to merge 1 commit into
openshift:mainfrom
midu16:RFE-9311

Conversation

@midu16

@midu16 midu16 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

When CPU partitioning is enabled (cpuPartitioningMode: AllNodes), must-gather pods now carry the workload partitioning annotation so CRI-O pins them to Reserved CPU cores, preventing interference with Isolated application workloads.

Changes:

  • Query Infrastructure resource to detect CPU partitioning mode
  • Annotate temp namespace with workload.openshift.io/allowed
  • Annotate pods with target.workload.openshift.io/management
  • Fail open if Infrastructure resource is unavailable

Summary by CodeRabbit

  • Enhancements

    • Must-gather resources now account for cluster CPU partitioning settings.
    • When CPU partitioning is enabled, must-gather namespaces and pods receive scheduling metadata to support appropriate workload placement.
  • Tests

    • Added coverage for CPU partitioning detection and conditional namespace and pod scheduling annotations.

When CPU partitioning is enabled (cpuPartitioningMode: AllNodes),
must-gather pods now carry the workload partitioning annotation
so CRI-O pins them to Reserved CPU cores, preventing interference
with Isolated application workloads.

Changes:
- Query Infrastructure resource to detect CPU partitioning mode
- Annotate temp namespace with workload.openshift.io/allowed
- Annotate pods with target.workload.openshift.io/management
- Fail open if Infrastructure resource is unavailable
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot

openshift-ci-robot commented Jul 22, 2026

Copy link
Copy Markdown

@midu16: This pull request references RFE-9311 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature request to target the "5.0.0" version, but no target version was set.

Details

In response to this:

When CPU partitioning is enabled (cpuPartitioningMode: AllNodes), must-gather pods now carry the workload partitioning annotation so CRI-O pins them to Reserved CPU cores, preventing interference with Isolated application workloads.

Changes:

  • Query Infrastructure resource to detect CPU partitioning mode
  • Annotate temp namespace with workload.openshift.io/allowed
  • Annotate pods with target.workload.openshift.io/management
  • Fail open if Infrastructure resource is unavailable

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 22, 2026
@openshift-ci
openshift-ci Bot requested review from ardaguclu and tchap July 22, 2026 19:12
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: midu16
Once this PR has been reviewed and has the lgtm label, please assign ardaguclu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Walkthrough

Must-gather now detects cluster-wide CPU partitioning and conditionally annotates its temporary namespace and pods for management workload scheduling. Tests cover enabled, disabled, and missing Infrastructure configurations.

Changes

Must-gather CPU partitioning

Layer / File(s) Summary
Detect and retain CPU partitioning mode
pkg/cli/admin/mustgather/mustgather.go
Reads the Infrastructure CPUPartitioning setting during Run() and stores whether it is enabled.
Apply workload annotations and validate resources
pkg/cli/admin/mustgather/mustgather.go, pkg/cli/admin/mustgather/mustgather_test.go
Conditionally adds workload annotations to the temporary namespace and must-gather pods, with tests for enabled, disabled, and missing-resource cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MustGatherOptions
  participant InfrastructureAPI
  participant Namespace
  participant Pod
  MustGatherOptions->>InfrastructureAPI: Read CPUPartitioning setting
  InfrastructureAPI-->>MustGatherOptions: Return partitioning status
  MustGatherOptions->>Namespace: Create with management workload annotation when enabled
  MustGatherOptions->>Pod: Create with management scheduling annotation when enabled
Loading
🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding workload partitioning support for must-gather pods.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed New and existing test names are static, descriptive strings; no It/Describe/Context/When titles use dynamic or generated values.
Test Structure And Quality ✅ Passed Plain table-driven unit tests, not Ginkgo; they use fake clients, no cluster resources, no indefinite waits, and assertions include messages.
Microshift Test Compatibility ✅ Passed Added tests are plain testing.T unit tests; no Ginkgo specs or MicroShift-unsupported e2e APIs were introduced.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added tests are plain Go unit tests, not Ginkgo e2e tests, and they contain no multi-node or HA assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Only workload annotations were added; no new replicas, anti-affinity, topology spread, or control-plane node selectors were introduced.
Ote Binary Stdout Contract ✅ Passed No main/init/TestMain/suite setup stdout writes were added; the only new stdout write is inside a cleanup closure, not process-level code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the changes are unit tests only and show no IPv4-only assumptions or external connectivity.
No-Weak-Crypto ✅ Passed Changed must-gather code only adds workload annotations; no crypto imports or MD5/SHA1/DES/RC4/3DES/Blowfish/ECB or secret comparisons appear in the touched files.
Container-Privileges ✅ Passed Diff only adds CPU-partitioning workload annotations; no new privileged/root/hostNetwork/allowPrivilegeEscalation/SYS_ADMIN settings were introduced.
No-Sensitive-Data-In-Logs ✅ Passed New logging only reports CPU-partitioning lookup failure; no passwords, tokens, PII, session IDs, or internal hostnames are newly logged.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
pkg/cli/admin/mustgather/mustgather_test.go (1)

790-801: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Compare the complete namespace annotation map.

The current assertions only inspect one key through multiple conditionals, so regressions to the other annotations would go unnoticed. Build the expected annotation map for each case and compare it with cmp.Diff.

Proposed test adjustment
-			_, exists := ns.Annotations[namespaceWorkloadAllowedAnnotation]
-			if tc.expectAnnotation && !exists {
-				t.Errorf("expected %s annotation, got annotations: %v", namespaceWorkloadAllowedAnnotation, ns.Annotations)
-			}
-			if !tc.expectAnnotation && exists {
-				t.Errorf("did not expect %s annotation when partitioning is disabled", namespaceWorkloadAllowedAnnotation)
-			}
-			if tc.expectAnnotation && ns.Annotations[namespaceWorkloadAllowedAnnotation] != "management" {
-				t.Errorf("expected annotation value %q, got %q", "management", ns.Annotations[namespaceWorkloadAllowedAnnotation])
+			expectedAnnotations := map[string]string{
+				"oc.openshift.io/command":    "oc adm must-gather",
+				"openshift.io/node-selector": "",
+			}
+			if tc.expectAnnotation {
+				expectedAnnotations[namespaceWorkloadAllowedAnnotation] = "management"
+			}
+			if diff := cmp.Diff(expectedAnnotations, ns.Annotations); diff != "" {
+				t.Errorf("namespace annotations differ (-want +got):\n%s", diff)
 			}

As per coding guidelines, tests should assemble expected objects and compare them using google/go-cmp.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/cli/admin/mustgather/mustgather_test.go` around lines 790 - 801, Update
the table-driven test around newNamespace to construct the complete expected
annotation map for each test case and compare it with ns.Annotations using
cmp.Diff. Remove the individual namespaceWorkloadAllowedAnnotation existence and
value conditionals, while preserving each case’s expected annotations.

Source: Coding guidelines

pkg/cli/admin/mustgather/mustgather.go (1)

322-322: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document all changed Go functions.

The changed declarations omit required descriptive comments:

  • pkg/cli/admin/mustgather/mustgather.go#L322-L322: document the Infrastructure lookup and fail-open behavior.
  • pkg/cli/admin/mustgather/mustgather.go#L1127-L1127: document conditional namespace workload annotation.
  • pkg/cli/admin/mustgather/mustgather_test.go#L725-L725: document the detection test.
  • pkg/cli/admin/mustgather/mustgather_test.go#L773-L773: document the namespace annotation test.

As per coding guidelines, all exported and unexported Go functions must have descriptive comments.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/cli/admin/mustgather/mustgather.go` at line 322, Document all four
changed Go functions with concise comments: in
pkg/cli/admin/mustgather/mustgather.go lines 322-322, describe
isCPUPartitioningEnabled’s Infrastructure lookup and fail-open behavior; in
lines 1127-1127, describe the conditional namespace workload annotation; in
pkg/cli/admin/mustgather/mustgather_test.go lines 725-725 and 773-773, describe
the CPU partitioning detection and namespace annotation tests respectively.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/cli/admin/mustgather/mustgather_test.go`:
- Around line 790-801: Update the table-driven test around newNamespace to
construct the complete expected annotation map for each test case and compare it
with ns.Annotations using cmp.Diff. Remove the individual
namespaceWorkloadAllowedAnnotation existence and value conditionals, while
preserving each case’s expected annotations.

In `@pkg/cli/admin/mustgather/mustgather.go`:
- Line 322: Document all four changed Go functions with concise comments: in
pkg/cli/admin/mustgather/mustgather.go lines 322-322, describe
isCPUPartitioningEnabled’s Infrastructure lookup and fail-open behavior; in
lines 1127-1127, describe the conditional namespace workload annotation; in
pkg/cli/admin/mustgather/mustgather_test.go lines 725-725 and 773-773, describe
the CPU partitioning detection and namespace annotation tests respectively.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: eecd613f-7845-4fa7-8eac-ea06fc83d1f8

📥 Commits

Reviewing files that changed from the base of the PR and between cd086f9 and 03a94e5.

📒 Files selected for processing (2)
  • pkg/cli/admin/mustgather/mustgather.go
  • pkg/cli/admin/mustgather/mustgather_test.go

@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@midu16: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-ci

openshift-ci Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants